﻿using System;
using NUnit.Framework;
using Smartkernel;

namespace Smartkernel.NUnitTest.
{
    [Category("Core")]
    [TestFixture]
    public class SmartMathTest
    {
        [Test]
        public void Test()
        {
            //【01】动态方法计算中缀表达式（涉及方法：DynamicEval）
            string expression = "12.5 + 12 / 2";
            Assert.AreEqual(SmartMath.DynamicEval(expression, true).ToString(), "18.5");
            Assert.AreEqual(SmartMath.DynamicEval(expression, false).ToString(), "18.5");

            //【02】解析的方法计算中缀表达式（涉及方法：Eval）
            Assert.AreEqual(SmartMath.Eval(expression), 18.5d);
            Assert.AreEqual(SmartAction.IsInvokeFail(delegate { SmartMath.Eval(expression.Replace(" ", "")); }), true);
        }
    }
}
